﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using SaleSystem;
using Sale_Operation;
using Sale_Model;
using Sale_Common;
namespace SaleSystem.Other
{
    public partial class SysUserList : PageBase
    {
        #region Page Event
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                bnNew.OnClientClick = win_Content.GetShowReference("SysUserEdit.aspx?Id=0");
                GetAndBind();
            }
        }
        protected void bnSearch_Click(object sender, EventArgs e)
        {
            GetAndBind();
        }

        protected void gv_List_RowCommand(object sender, ExtAspNet.GridCommandEventArgs e)
        {
            if (e.CommandName.ToLower() == "delete")
            {
                SysUser SM = new SysUser();
                SM.SUser_Id = ValueHandler.GetIntNumberValue(gv_List.DataKeys[e.RowIndex][0]);
                SM.SUser_Name=ValueHandler.GetStringValue(gv_List.DataKeys[e.RowIndex][0]);
                bool blRes = Manager.Delete(SM);
                if (blRes)
                {
                    GetAndBind();
                    ExtAspNet.Alert.Show("用户删除成功！", ExtAspNet.MessageBoxIcon.Information);
                }
                else
                    ExtAspNet.Alert.Show("用户删除失败！", ExtAspNet.MessageBoxIcon.Error);
            }

        }
        #endregion
        #region Method
        private void GetAndBind()
        {
            FormatGrid(gv_List);   
            dtList = Manager.GetList("");
            gv_List.DataSource = dtList;
            gv_List.DataBind();    
        }
        #endregion
        #region Property
        SysUsersOp Manager = new SysUsersOp();
        #endregion

    }
}
